<template>
  <div class="photoBox">
    <div class="display_Diagram" v-if="picture == ''&&multiGraphList.length>=1">
      <video
        class="video"
        v-if="multiGraphList[0].judge == true"
        controls
        controlsList="nodownload"
        :src="informationData.buildingVideo"
        :poster="informationData.videoCover"
      ></video>
      <PublicImage
        class="img"
        v-else-if="multiGraphList[0].judge == false"
        :src="multiGraphList[0].name"
      ></PublicImage>
      <PublicImage
        class="img"
        v-else
        :src="require('@/assets/image/finance/product_dj.png')"
      ></PublicImage>
    </div>
    <div class="display_Diagram" v-else-if="picture == ''">
      <video
        v-if="informationData.buildingVideo!=''"
        :src="informationData.buildingVideo"
        :poster="informationData.videoCover"
        class="video"
        controls
        controlsList="nodownload"
      ></video>
      <PublicImage
        class="img"
        v-else-if="informationData.videoCover!=''"
        :src="informationData.videoCover"
      ></PublicImage>
      <PublicImage
        class="img"
        v-else
        :src="require('@/assets/image/finance/product_dj.png')"
      ></PublicImage>
    </div>

    <div class="display_Diagram" v-else>
      <video class="video" controls v-if="picture.judge == true" :src="informationData.buildingVideo" controlsList="nodownload" :poster="informationData.videoCover"></video>
      <PublicImage
        class="img"
        v-if="picture.judge == false"
        :src="picture.name"
      ></PublicImage>
    </div>

    <div class="multiGraph">
      <div
        class="small_Picture"
        :style="transform"
        v-for="(item,index) in multiGraphList"
        :key="index"
        @click="onMultiGraph(item)"
        :class="[rotationId==index?'chart':'']"
      >
        <PublicImage
          class="img"
          v-if="item ==''"
          :src="require('@/assets/image/finance/product_dj.png')"
        ></PublicImage>
        <PublicImage
          class="img"
          v-else-if="item.judge == true"
          :src="item.name"
        ></PublicImage>
        <PublicImage
          class="img"
          v-else
          :src="item.name"
        ></PublicImage>
      </div>
    </div>
    <!-- 轮播图左右切换 -->
    <div class="switch" v-if="multiGraphList.length>5">
      <div class="Turn_left" @click="onTurn_left"></div>
      <div class="Turn_right" @click="onTurn_right"></div>
    </div>
  </div>
</template>

<script>
export default {
  props:{
    multiGraphList:{
      type:Array,
      default:[]
    },
    informationData:{
      type:Object,
      default:{}
    }
  },
  data(){
    return {
      picture: '',
      rotationId: 0, //轮播图id
      transform: {
        transform: 'translateX(0px)',
      },
    }
  },
  methods:{
    //左滑动
    onTurn_left() {
      this.count = this.rotationId
      if (this.count == 0) {
        this.count = this.multiGraphList.length - 1
        this.transform = {
          transform: 'translateX(-458.15px)',
        }
      } else {
        this.count--
      }

      this.multiGraphList.forEach((item, index) => {
        // console.log(item, '左滑动')
        if (this.count == index) {
          this.picture = item
          this.rotationId = this.picture.id
          if (this.rotationId < 5) {
            this.fontSize = 0
            this.transform = {
              transform: 'translateX(0px)',
            }
          }
        }
      })
    },
    //右滑动
    onTurn_right() {
      this.count = this.rotationId
      if (this.count == this.multiGraphList.length - 1) {
        this.count = 0
        this.transform = {
          transform: 'translateX(0px)',
        }
      } else {
        this.count++
      }
      // console.log(this.count, '')
      this.multiGraphList.forEach((item, index) => {
        // console.log(item, '右滑动')
        if (this.count == index) {
          this.picture = item
          this.rotationId = this.picture.id
          if (this.rotationId > 4) {
            this.fontSize = -458.15
            this.transform = {
              transform: 'translateX(-458.15px)',
            }
          }
        }
      })
    },
    //图片点击切换
    onMultiGraph(item) {
      this.picture = item
      this.rotationId = this.picture.id
      // console.log(this.picture)
    },
  }
}
</script>

<style lang="scss" scoped>
  .photoBox {
    flex: 0 0 460px;
    width: 460px;
    height: 317px;
    background-color: #bbbbbb;
    margin-right: 30px;
    .display_Diagram {
      width: 100%;
      height: 277px;
      display: flex;
      margin-top: 20px;
      .img {
        width: 100%;
        height: 275px;
      }

      .video {
        width: 100%;
        height: 275px;
      }
    }
    .multiGraph {
      margin-top: 40px;
      height: 77px;
      display: flex;
      overflow: hidden;
      .small_Picture {
        margin-right: 13.5px;
        height: 77px;
        width: 81px;
        position: relative;
        z-index: 99;
        border: 1px solid transparent;
        .img {
          height: 75px;
          width: 79px;
          object-fit: cover;
        }
      }
      .chart {
        border: 1px solid red;
      }
      .small_Picture:nth-of-type(1) {
        z-index: 99;
      }
      .small_Picture:nth-of-type(5) {
        float: left;
        margin-right: 0px;
        z-index: 99;
      }
      .small_Picture:nth-of-type(6) {
        margin-left: 10px;
      }
    }
    ::-webkit-scrollbar {
      border: none;
    }
    .switch {
      display: flex;
      justify-content: space-between;
      position: relative;
      top: -14%;
      .Turn_left {
        position: relative;
        width: 21px;
        height: 36px;
        opacity: 0.4;
        background: #333333;
        top: -12px;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: url("../../../assets/image/jiantoukongxin_left_01.png");
        background-repeat: no-repeat;
        background-position: 50% 50%;
        z-index: 99;
      }
      .Turn_right {
        position: relative;
        width: 21px;
        height: 36px;
        opacity: 0.4;
        background: #333333;
        top: -12px;
        left: 0;
        right: 0;
        bottom: 0;
        background-image: url("../../../assets/image/jiantoukongxin_right_01.png");
        background-repeat: no-repeat;
        background-position: 50% 50%;
        z-index: 99;
      }
    }
  }

</style>